/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package me.yobol.algorithm.inaction.netease;

import java.nio.file.Files;
import java.util.Scanner;

/**
 *
 * @author Yobol
 */
public class Demo03 {

    public static int diff(String str) {
        int movementTimes = 0;
        char c = str.charAt(0);
        int last = 0;
        for (int i = 1; i < str.length(); i++) {
            int temp = 0;
            if (str.charAt(i) != c) {
                continue;
            }
            
            if (str.charAt(i) == c) {
                for (int j = last + 1; j < i; j++) {
                    if (str.charAt(j) != c) {
                        temp++;
                    }
                }
            }
            movementTimes += temp;
        }
        return movementTimes;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNext()) {
            String str = in.nextLine();
            System.out.println(diff(str));
        }
    }
}
